--- id: TASK-033 title: 'TUI: Auto-select dark/light theme based on macOS appearance' status: To Do assignee: [] created_date: '2026-06-12 04:21' labels: - tui - enhancement dependencies: - TASK-021 priority: low ordinal: 33000 --- ## Description On startup, detect macOS Dark Mode and choose the matching theme variant automatically, rather than always defaulting to `flexoki`. Detection: ```python import subprocess result = subprocess.run( ["defaults", "read", "-g", "AppleInterfaceStyle"], capture_output=True, text=True ) is_dark = result.returncode == 0 and "Dark" in result.stdout ``` Startup behavior: - If state file (TASK-021) has a saved theme: use it as-is (user explicitly chose it) - If no saved theme: pick `flexoki-dark` when Dark Mode is on, `flexoki` when off - `t` cycling still works normally and saves to state file - A `--no-auto-theme` CLI flag or constant at top of file disables this behavior ## Acceptance Criteria - [ ] #1 First launch with no saved theme picks dark variant in Dark Mode, light variant otherwise - [ ] #2 Saved theme from state file takes priority over auto-detection - [ ] #3 Detection failure (non-macOS, permission error) falls back to flexoki silently - [ ] #4 Auto-detection runs synchronously before the app loop starts (no flash of wrong theme)